/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ads.tools;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.TreeMap;

/**
 *
 * @author framet-lap
 */
public class Main {
    public static void main(String[] args){
        HashMap<Integer, Integer> hashmap = new HashMap<>();
        TreeMap<Integer, Integer> treemap = new TreeMap<>();
        
        int units = 100000;
        
        System.out.println("Put 100000 objects");
        long timeInMillis = System.currentTimeMillis();
        for(int i = 0;i <units; i++){
            treemap.put(i, i);
        }
        timeInMillis = System.currentTimeMillis()-timeInMillis;
        System.out.println("TreeMap time in millis: "+timeInMillis);
        timeInMillis = System.currentTimeMillis();
        for(int i = 0;i <units; i++){
            hashmap.put(i, i);
        }
        timeInMillis = System.currentTimeMillis()-timeInMillis;
        System.out.println(timeInMillis);
        System.out.println(System.currentTimeMillis());
        System.out.println("TreeMap time in millis: "+timeInMillis);
        
        System.out.println("");
        System.out.println("Loop through every entry");
        timeInMillis = System.currentTimeMillis();
        for(int i = 0;i <units; i++){
            treemap.get(i);
        }
        timeInMillis = System.currentTimeMillis()-timeInMillis;
        System.out.println("TreeMap time in millis: "+timeInMillis);
        timeInMillis = System.currentTimeMillis();
        for(int i = 0;i <units; i++){
            hashmap.get(i);
        }
        timeInMillis = System.currentTimeMillis()-timeInMillis;
        System.out.println(timeInMillis);
        System.out.println(System.currentTimeMillis());
        System.out.println("TreeMap time in millis: "+timeInMillis);
        
        System.out.println("");
        System.out.println("Delete through every entry");
        timeInMillis = System.currentTimeMillis();
        for(int i = 0;i <units; i++){
            treemap.remove(i);
        }
        timeInMillis = System.currentTimeMillis()-timeInMillis;
        System.out.println("TreeMap time in millis: "+timeInMillis);
        timeInMillis = System.currentTimeMillis();
        for(int i = 0;i <units; i++){
            hashmap.remove(i);
        }
        timeInMillis = System.currentTimeMillis()-timeInMillis;
        System.out.println(timeInMillis);
        System.out.println(System.currentTimeMillis());
        System.out.println("TreeMap time in millis: "+timeInMillis);
    }
}
